#include "IEffect.h"
#include "IRenderDevice.h"

namespace Rz { namespace Graphics { namespace Render {

void IEffect::AddProperty(IEffectProperty* property)
{
	_propertyCollection.Add(property);
}

void IEffect::RemoveProperty(IEffectProperty* property)
{
	_propertyCollection.Remove(property);
}

const Collections::List<Ptr<IEffectProperty>>& IEffect::GetPropertyCollection() const
{
	return _propertyCollection;
}

Collections::List<Ptr<IEffectProperty>>& IEffect::GetPropertyCollection()
{
	return _propertyCollection;
}

IEffectProperty* IEffect::GetPropertyByName(const String& name)
{
	for (auto& e : _propertyCollection)
	{
		if (name == e->GetPropertyName())
		{
			return e;
		}
	}

	return nullptr;
}

const IEffectProperty* IEffect::GetPropertyByName(const String& name) const
{
	for (auto& e : _propertyCollection)
	{
		if (name == e->GetPropertyName())
		{
			return e;
		}
	}

	return nullptr;
}

const IEffectProperty* IEffect::GetPropertyByIndex(u32 index) const
{
	return _propertyCollection[index];
}

IEffectProperty* IEffect::GetPropertyByIndex(u32 index)
{
	return _propertyCollection[index];
}

const IEffectProperty* IEffect::operator[] (const String& name) const
{
	return this->GetPropertyByName(name);
}

IEffectProperty* IEffect::operator[] (const String& name)
{
	return this->GetPropertyByName(name);
}

const IEffectProperty* IEffect::operator[] (u32 index) const
{
	return _propertyCollection[index];
}

IEffectProperty* IEffect::operator[] (u32 index)
{
	return _propertyCollection[index];
}

} } }

